from multiprocessing import Pool
from threading import Thread,Lock,current_thread
import time,os,threading
# 售票数量
tickets=50
lock=Lock()
def sale_ticket():
    global tickets
    #每个窗口有100人排队
    for i in range(100):
        lock.acquire_lock()#上锁
        if tickets>0:
            print(f'{current_thread().name}正在售第{tickets}张票')
            tickets-=1
            # time.sleep(0.5)
        else:
            break
        lock.release_lock()#解锁

if __name__=='__main__':
    for i in range(3):
        t=Thread(target=sale_ticket)
        t.start()










